Load the packages:

library(tidyverse)
library(lubridate)
library(knitr)
library(DT)
library(here)
library(plotly)

Read in the Netflix viewing activity:

raw_di <- read_csv(here("data", "raw", "NetflixViewingHistory_Diana.csv"))
raw_bri <- read_csv(here("data", "raw", "NetflixViewingHistory_Brian.csv"))
raw_vic <- read_csv(here("data", "raw", "NetflixViewingHistory_Vicky.csv"))
raw_kev <- read_csv(here("data", "raw", "NetflixViewingHistory_Kevin.csv"))

Diana’s Viewing Activity

Brian’s Viewing Activity

Vicky’s Viewing Activity

Kevin’s Viewing Activity

Data Processing

Label each item with User:

processed_di <- raw_di %>%
  mutate(User = "Diana")

processed_bri <- raw_bri %>%
  mutate(User = "Brian")

processed_vic <- raw_vic %>%
  mutate(User = "Vicky")

processed_kev <- raw_kev %>%
  mutate(User = "Kevin")

Combine the datasets together:

data <- rbind(processed_di,processed_bri,processed_vic,processed_kev)

Count the titles:

processed <- data %>%
  group_by(year(Date), month(Date, label = TRUE), User) %>%
  summarise(count = n()) %>%
  rename(Year = `year(Date)`,
         Month = `month(Date, label = TRUE)`) %>%
  complete(Year, Month, User) %>%
  mutate(count = replace_na(count, 0))

Summary

Plot the data:

history <- processed %>%
  filter(Year != 2020) %>%
  ggplot(aes(x = Month, colour = User, text = paste0("Month: ", Month, "</br></br> Count: ", count))) +
  geom_line(aes(x = Month, y = count, group = User)) +
  geom_point(aes(x = Month, y = count, color = User), shape = 20) +
  facet_wrap(~ Year, ncol = 3) +
  labs(title = "Netflix Viewing History",
       x = "Month",
       y = "Count") +
  theme(text = element_text(size = 12),
        axis.text.x = element_text(angle = 90))

ggplotly(history, tooltip = c("text"))

Plot the 2020 data:

tt <- data %>%
  filter(year(Date) == 2020) %>%
  group_by(Date, User) %>%
  summarise(count = n()) %>%
  ggplot(aes(x = Date, colour = User, text = paste0("Date: ", month(Date, label = TRUE), " ", day(Date), ", ", year(Date), "</br></br>Count: ",count))) +
  geom_line(aes(x = Date, y = count, group = User)) +
  geom_point(aes(x = Date, y = count, color = User), shape = 20) +
  labs(title = "Netflix Viewing (2020)",
       x = "Date",
       y = "Count") +
  theme(text = element_text(size = 12),
        axis.text.x = element_text(angle = 90))

ggplotly(tt, tooltip = c("text"))